<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
<textarea id="text" style="margin: 0px; width: 623px; height: 64px;">
    {"fromUid":5,"groupId":0,"msg":"0e27190af0a54655ad2a37a72fba69bd","time":1601024118164,"toUid":0,"type":2,
"typeSmall":21,msgId:"uuid---"}
    </textarea>
<input type="submit" value="send" onclick="send()">
<div id="msg"></div>
<script>
    var msg = document.getElementById("msg");
    var wsServer = 'ws://127.0.0.1:9999/chat';
    var ws = new WebSocket(wsServer);
    ws.onopen = function (evt) {
        msg.innerHTML = "The connection is open"; };
    ws.onmessage = function (evt) {
        msg.innerHTML = evt.data + "<br>" + msg.innerHTML;
    };
    ws.onclose = function (evt) {
        alert("连接关闭");
    };
    function send() {
        var text = document.getElementById("text").value;
        ws.send(text);
    }
</script>
</body>
</html>